package org.example;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/22
 * Time: 21:51
 */
public class Solution {
    public int peakIndexInMountainArray(int[] arr) {
        int left = 0,right = arr.length - 1,mid = right / 2;
        while (left < right) {
            if (arr[mid] < arr[mid + 1]){
                left = mid + 1;
            }
            if (arr[mid] > arr[mid + 1]){
                right = mid;
            }
            mid = left + (right - left) / 2;
        }
        return left;
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        int ret = solution.peakIndexInMountainArray(new int[]{0,3,6,9,10,5,2});
        System.out.println(ret);
    }
}